# -*- coding: utf-8 -*-

from sklearn.preprocessing import LabelEncoder
import numpy as np

def refomat(X_features,Y):
    
    # =========================================================================
    # Aim: transfer labels from string ('Art') to numbers (1)
    # Input: X(dict), Y
    # Output: X_trian,X_test,Y_train (encoded), Y_test (encoded), le (encoder)
    # =========================================================================
    
    train_feature = X_features['train']
    train_category = Y['train']
    test_feature = X_features['test']
    test_category = Y['test']

    all_category = np.unique(np.hstack((train_category,test_category)))

    le = LabelEncoder()
    le.fit(all_category)

    train_category = le.transform(train_category)
    test_category = le.transform(test_category)

    return train_feature,test_feature,train_category,test_category,le